<?php

namespace App\Admin\Eloquent;

class Users extends Model
{
	 /**
     * 分页模糊查询
     *
     * @param  array  $options
     * @param  int  $perPage
     * @return \App\Admin\Eloquent\Role[]
     */
    public static function paginateQuery(array $options = [], int $perPage = 15)
    {
        $query = static::query();

        if (isset($options['search']) && !empty($options['search'])) {
            $condition = '%' . $options['search'] . '%';
            $query = $query->where('username', 'like', $condition);
        }

        return $query->orderBy('created_at', 'desc')->paginate($perPage);
    }
}